-directive_meta_kind = params[:directive_meta_kind].presence || 'directive'
-program_kind = params[:program_kind].presence

-content_for :modal_title do
  -if params[:program_id].present?
    Select #{directive_meta_kind.titleize.pluralize}
  -else
    Select Programs

-if params[:program_id].present?
  -content_for :modal_help, :select_program_directives
-else
  -content_for :modal_help, :select_directive_programs

%script#program_option{ :type => 'text/html', :'data-prefix' => 'program' }
  %li{ :'data-id' => '<%= program.id %>', :'data-title' => '<%= program.title %>', :'data-slug' => '<%= program.slug %>' }
    .row-fluid
      .span8
        %span.name <%= program.title %>
        %span.option <%= program.slug %>
      .span4.actions
        .pull-right
          %a.widgetbtn.btn.btn-mini.add-me{:href => "#", :'data-toggle' => 'selector-list-select'}
            %i.grcicon-chevron-right

%script#program_option_data{ :type => 'text/html' }
  %span.name <%= program.title %>
  %span.option <%= program.slug %>

%script#program_selected{ :type => 'text/html', :'data-mappings' => 'child:program,object:program', :'data-member' => 'program_directive' }
  %li{ :'data-id' => '<%= id %>', :'data-object-id' => '<%= program.id %>' }
    .row-fluid
      .span6.object_info{ :'data-template-id' => 'program_option_data' }
      .span6.actions
        %span.state
        .pull-right
          %input{ :type => 'hidden', :name => 'items[<%= id %>][id]', :value => '<% if (id.toString().substr(0,3) != "new") { %><%= id %><% } %>'.html_safe }
          %input{ :type => 'hidden', :name => 'items[<%= id %>][directive_id]', :value => object.id }
          %input{ :type => 'hidden', :name => 'items[<%= id %>][program_id]', :value => '<%= program.id %>' }
          %input._destroy{ :type => 'hidden', :name => 'items[<%= id %>][_destroy]', :value => '' }
          %a.widgetbtn.btn.btn-mini{ :href => '#', :'data-toggle' => 'selector-list-remove' }
            %i.grcicon-remove

%script#directive_option{ :type => 'text/html', :'data-prefix' => 'directive' }
  %li{ :'data-id' => '<%= directive.id %>', :'data-title' => '<%= directive.title %>', :'data-slug' => '<%= directive.slug %>' }
    .row-fluid
      .span8
        .object-info
          %span.name <%= directive.title %>
          %span.option <%= directive.slug %>
        
      .span4.actions
        .pull-right
          %a.widgetbtn.btn.btn-mini.add-me{:href => "#", :'data-toggle' => 'selector-list-select'}
            %i.grcicon-chevron-right

%script#directive_option_data{ :type => 'text/html' }
  .object-info
    %span.name <%= directive.title %>
    %span.option <%= directive.slug %>

%script#directive_selected{ :type => 'text/html', :'data-mappings' => 'child:directive,object:directive', :'data-member' => 'program_directive' }
  %li{ :'data-id' => '<%= id %>', :'data-object-id' => '<%= directive.id %>' }
    .row-fluid
      .span6.object_info{ :'data-template-id' => 'directive_option_data' }
      .span6.actions
        %span.state
        .pull-right
          %input{ :type => 'hidden', :name => 'items[<%= id %>][id]', :value => '<% if (id.toString().substr(0,3) != "new") { %><%= id %><% } %>'.html_safe }
          %input{ :type => 'hidden', :name => 'items[<%= id %>][program_id]', :value => object.id }
          %input{ :type => 'hidden', :name => 'items[<%= id %>][directive_id]', :value => '<%= directive.id %>' }
          %input._destroy{ :type => 'hidden', :name => 'items[<%= id %>][_destroy]', :value => '' }
          %a.widgetbtn.btn.btn-mini{ :href => '#', :'data-toggle' => 'selector-list-remove' }
            %i.grcicon-remove

-if params[:program_id].present?
  .row-fluid.modal-source
    .span6
      .row-fluid
        .span7
          %h3
            Add #{directive_meta_kind.titleize}
            %a.widgetbtn.widgetbtnselector.btn.btn-add{ :href => new_flow_directive_path(:meta_kind => directive_meta_kind), :'data-toggle' => 'modal-ajax-listnewform', :'data-selector-target' => '.source, .target', :'data-modal-class' => 'modal-wide' }
              %i.grcicon-add
        .span5
          %input.widgetsearch.input-block-level{:type => "text", :placeholder => "Search Directives"}

      .filter-block
        .row-fluid
          .span12
            .tabbable.tabs-left
              .tab-content
                #category1.tab-pane.active
                  .people-list
                    %ul.source{ :'data-list-data-href' => flow_directives_path(:meta_kind => directive_meta_kind, :format => :json), :'data-template-id' => 'directive_option' }
    .span6
      %h3
        #{directive_meta_kind.titleize.pluralize} for this Program
      .people-list.currentlist
        %ul.target{ :'data-list-data-href' => flow_program_directives_path(:program_id => object.id, :directive_meta_kind => directive_meta_kind, :program_kind => program_kind, :format => :json), :'data-selector-target' => '.source, .target', :'data-template-id' => 'directive_selected'}
-else
  .row-fluid.modal-source
    .span6
      .row-fluid
        .span7
          %h3
            Add Program
            %a.widgetbtn.widgetbtnselector.btn.btn-add{ :href => new_flow_program_path(:kind => program_kind), :'data-toggle' => 'modal-ajax-listnewform', :'data-selector-target' => '.source, .target', :'data-modal-class' => 'modal-wide' }
              %i.grcicon-add
        .span5
          %input.widgetsearch.input-block-level{:type => "text", :placeholder => "Search Programs"}

      .filter-block
        .row-fluid
          .span12
            .tabbable.tabs-left
              .tab-content
                #category1.tab-pane.active
                  .people-list
                    %ul.source{ :'data-list-data-href' => flow_programs_path(:kind => program_kind, :format => :json), :'data-template-id' => 'program_option' }
    .span6
      %h3
        Programs for this Directive
      .people-list.currentlist
        %ul.target{ :'data-list-data-href' => flow_program_directives_path(:directive_id => object.id, :directive_meta_kind => directive_meta_kind, :program_kind => program_kind, :format => :json), :'data-selector-target' => '.source, .target', :'data-template-id' => 'program_selected'}

